#include <ACUASuart.h>

void uart_read_line(unsigned char * c_array, uint8_t max, int try_sec)
{
	uint8_t i=0;
	unsigned long z = 0, tries = F_CPU / 160UL * try_sec + 10*max;
	c_array[0] = 0;

	while(1)
	{
		if(z++ > tries) return;							// Timeout: give up after <try_sec> seconds
		c_array[i]=uart_getc();
		if(c_array[i]!=0 && c_array[i]!=10) // A (non-LF) character was received
																				// A possible LF from last sentence is skipped
		{
			if(c_array[i]==13 || i==max)
				{c_array[i]=0; break;}
			else if(c_array[i])
				i++;
		}
	}
}

